﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;
using com.lover.astd.common.model.enumer;

namespace com.lover.astd.common.logicexe.activities
{
    public class GemFlopExe : ExeBase
    {
        public GemFlopExe() { _name = ConfigStrings.S_GemFlop; _readable = ConfigStrings.SR_GemFlop; }
        public override long execute()
        {
            if (!_user.isActivityRunning(ActivityType.GemFlop)) return next_hour();
            Dictionary<string, string> conf = getConfig();
            if (!conf.ContainsKey(ConfigStrings.enabled) || !conf[ConfigStrings.enabled].ToLower().Equals("true")) return an_hour_later();
            int _maxUpgrade = 0;
            if (conf.ContainsKey(ConfigStrings.max_upgrade)) Int32.TryParse(conf[ConfigStrings.max_upgrade], out _maxUpgrade);
            ActivityMgr mgr = ServiceFactory.getActivityManager();

            int result = mgr.handleGemFlopInfo(_proto, _logger, getGemPrice(), getGoldAvailable(), _maxUpgrade);
            if (result == 2 || result == 10) return next_day();
            if (result == 1) return next_hour();
            else return immediate();
        }
    }
}
